package com.jfinal.winxin.sdk.api;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import com.jfinal.weixin.sdk.api.AccessTokenApi;
import com.jfinal.weixin.sdk.utils.HttpUtils;
import com.jfinal.weixin.sdk.utils.JsonUtils;

public class QrCodeFromWinxinExtApi {
  private static String WXACODEURLNORMAL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=";
  
  /**
   * 获取二维码图片
   * @return 
   */
  public static InputStream getQrCodeImg(String path) {
    
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("path", path);
    params.put("width", 430);
    String url = WXACODEURLNORMAL + AccessTokenApi.getAccessTokenStr();
    return HttpUtils.download(url, JsonUtils.toJson(params));
  }
}
